"You will be logged out automatically in %d seconds.",
seconds).format(seconds);
},
+ showBatteryWarning: false,
confirmButtons: [{ signal: 'ConfirmedLogout',
label: C_("button", "Log Out") }],
iconStyleClass: 'end-session-dialog-logout-icon',
seconds).format(seconds);
},
checkBoxText: C_("checkbox", "Install pending software updates"),
+ showBatteryWarning: true,
confirmButtons: [{ signal: 'ConfirmedReboot',
label: C_("button", "Restart") },
{ signal: 'ConfirmedShutdown',
"The system will restart automatically in %d seconds.",
seconds).format(seconds);
},
+ showBatteryWarning: false,
confirmButtons: [{ signal: 'ConfirmedReboot',
label: C_("button", "Restart") }],
iconName: 'view-refresh-symbolic',
"The system will automatically restart and install updates in %d seconds.",
seconds).format(seconds);
},
+ showBatteryWarning: true,
confirmButtons: [{ signal: 'ConfirmedReboot',
label: C_("button", "Restart & Install") }],
iconName: 'view-refresh-symbolic',
const LogindSession = Gio.DBusProxy.makeProxyWrapper(LogindSessionIface);
+const UPowerIface = '<node> \
+<interface name="org.freedesktop.UPower"> \
+ <property name="OnBattery" type="b" access="read"/> \
+</interface> \
+</node>';
+
+const UPowerProxy = Gio.DBusProxy.makeProxyWrapper(UPowerIface);
+
function findAppFromInhibitor(inhibitor) {
let desktopFile;
try {
this._updatesFile = Gio.File.new_for_path('/system-update');
this._preparedUpdateFile = Gio.File.new_for_path('/var/lib/PackageKit/prepared-update');
+ this._powerProxy = new UPowerProxy(Gio.DBus.system,
+ 'org.freedesktop.UPower',
+ '/org/freedesktop/UPower',
+ Lang.bind(this, function(proxy, error) {
+ if (error) {
+ log(error.message);
+ return;
+ }
+ this._powerProxy.connect('g-properties-changed',
+ Lang.bind(this, this._sync));
+ this._sync();
+ }));
+
this._secondsLeft = 0;
this._totalSecondsToStayOpen = 0;
this._applications = [];
this._checkBox.actor.connect('clicked', Lang.bind(this, this._sync));
messageLayout.add(this._checkBox.actor);
+ this._batteryWarning = new St.Label({ style_class: 'end-session-dialog-warning',
+ text: _("Running on battery power: please plug in before installing updates.") });
+ this._batteryWarning.clutter_text.ellipsize = Pango.EllipsizeMode.NONE;
+ this._batteryWarning.clutter_text.line_wrap = true;
+ messageLayout.add(this._batteryWarning);
+
this._scrollView = new St.ScrollView({ style_class: 'end-session-dialog-list' });
this._scrollView.set_policy(Gtk.PolicyType.NEVER, Gtk.PolicyType.AUTOMATIC);
this.contentLayout.add(this._scrollView,
if (dialogContent.subjectWithUpdates && this._checkBox.actor.checked)
subject = dialogContent.subjectWithUpdates;
+ if (dialogContent.showBatteryWarning) {
+ // Warn when running on battery power
+ if (this._powerProxy.OnBattery && this._checkBox.actor.checked)
+ this._batteryWarning.opacity = 255;
+ else
+ this._batteryWarning.opacity = 0;
+ }
+
let description;
let displayTime = _roundSecondsToInterval(this._totalSecondsToStayOpen,
this._secondsLeft,
this._checkBox.actor.visible = (dialogContent.checkBoxText && preparedUpdate && updatesAllowed);
this._checkBox.actor.checked = (preparedUpdate && updateAlreadyTriggered);
+ // We show the warning either together with the checkbox, or when
+ // updates have already been triggered, but the user doesn't have
+ // enough permissions to cancel them.
+ this._batteryWarning.visible = (dialogContent.showBatteryWarning &&
+ (this._checkBox.actor.visible || preparedUpdate && updateAlreadyTriggered && !updatesAllowed));
+
this._updateButtons();
if (!this.open(timestamp)) {